package com.zhiyou100.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhiyou100.dao.UserDao;
import com.zhiyou100.exception.LoginException;
import com.zhiyou100.model.User;
@Service
public class UserServiceImpl implements UserService{
	@Autowired
	private UserDao userDao;
	@Override
	public User login(User user) {
		User savedUser = userDao.findByAccount(user.getAccount());
		
		if(savedUser == null) {
			
			throw new LoginException(403001,"账号不存在");
		}
		if(!savedUser.getPassword().equals(user.getPassword())) {
			
			throw new LoginException(403002,"密码错误");
		}

				return savedUser;
	}

}
